<?php
const FOLDER_DATA = "./db/";

const PREMIER_LEAGUE    = 1;
const LIGA              = 2;
const SERIE_A           = 3;
const BUNDESLIGA        = 4;
const LIGUE_1           = 5;

const ARSENAL_FC                = 1;
const ASTON_VILLA_FC            = 2;
const BURNLEY                   = 501;
const CHELSEA_FC                = 7;
const CRYSTAL_PALACE            = 504;
const EVERTON_FC                = 8;
const HULL_CITY                 = 466;
const LEICESTER_CITY            = 467;
const LIVERPOOL_FC              = 10;
const MANCHESTER_CITY_FC        = 11;
const MANCHESTER_UNITED_FC      = 12;
const NEWCASTLE_UNITED_FC       = 13;
const QPR                       = 468;
const SOUTHAMPTON_FC            = 789;
const STOKE_CITY_FC             = 14;
const SUNDERLAND_AFC            = 15;
const SWANSEA_CITY              = 515;
const TOTTENHAM_HOTSPUR_FC      = 16;
const WEST_BROMWICH_ALBION_FC   = 17;
const WEST_HAM_UNITED_FC        = 18;

Team::add(PREMIER_LEAGUE, ARSENAL_FC                , "Arsenal FC"              );
Team::add(PREMIER_LEAGUE, ASTON_VILLA_FC            , "Aston Villa FC"          );
Team::add(PREMIER_LEAGUE, BURNLEY                   , "Burnley"                 );
Team::add(PREMIER_LEAGUE, CHELSEA_FC                , "Chelsea FC"              );
Team::add(PREMIER_LEAGUE, CRYSTAL_PALACE            , "Crystal Palace"          );
Team::add(PREMIER_LEAGUE, EVERTON_FC                , "Everton FC"              );
Team::add(PREMIER_LEAGUE, HULL_CITY                 , "Hull City"               );
Team::add(PREMIER_LEAGUE, LEICESTER_CITY            , "Leicester City"          );
Team::add(PREMIER_LEAGUE, LIVERPOOL_FC              , "Liverpool FC"            );
Team::add(PREMIER_LEAGUE, MANCHESTER_CITY_FC        , "Manchester City FC"      );
Team::add(PREMIER_LEAGUE, MANCHESTER_UNITED_FC      , "Manchester United FC"    );
Team::add(PREMIER_LEAGUE, NEWCASTLE_UNITED_FC       , "Newcastle United FC"     );
Team::add(PREMIER_LEAGUE, QPR                       , "QPR"                     );
Team::add(PREMIER_LEAGUE, SOUTHAMPTON_FC            , "Southampton FC"          );
Team::add(PREMIER_LEAGUE, STOKE_CITY_FC             , "Stoke City FC"           );
Team::add(PREMIER_LEAGUE, SUNDERLAND_AFC            , "Sunderland AFC"          );
Team::add(PREMIER_LEAGUE, SWANSEA_CITY              , "Swansea City"            );
Team::add(PREMIER_LEAGUE, TOTTENHAM_HOTSPUR_FC      , "Tottenham Hotspur FC"    );
Team::add(PREMIER_LEAGUE, WEST_BROMWICH_ALBION_FC   , "West Bromwich Albion FC" );
Team::add(PREMIER_LEAGUE, WEST_HAM_UNITED_FC        , "West Ham United FC"      );

class League
{
    public $id;
    public $name;

    function League($id, $name)
    {
        $this->id   = $id;
        $this->name = $name;
    }
}

class Team
{
    private static $teams = array();
    private $league;
    private $id;
    private $name;

    public function Team($league, $id, $name)
    {
        $this->league   = $league;
        $this->id       = $id;
        $this->name     = $name;
    }

    public static function add($league, $id, $name)
    {
        if (!array_key_exists($id, self::$teams))
        {
            $team = new Team($league, $id, $name);
            self::$teams[$team->id] = $team;
        }
    }

    public function getLeague() { return $this->league; }
    public function getId()     { return $this->id;     }
    public function getName()   { return $this->name;   }

    public static function getTeams()  { return self::$teams;  }
}
